package game.gui.info;

import game.controller.GameController;
import game.controller.NationInstance;
import game.controller.Region.LandRegion;
import game.controller.Unit.MilitaryUnit;
import game.util.GameMsg;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
 * NationInfoPanel.java  Date Created: 09 14, 2013
 *
 * Purpose: To display a nation's asset info.
 *
 * Description:  This class will display all information relavent to a nation.
 * Including: Military, Territory, Production Value, Production Saved, Paps,
 * Maybe: War Dec, Alliances, Grace, Reverse Grace
 *
 * @author Chris
 */
public class NationInfoPanel extends JPanel {
    private GameController controller;
    private NationInstance nation;
    private ArrayList<MilitaryUnit> military;
    private ArrayList<LandRegion> territory;
    private int nationNumber;

    public NationInfoPanel(GameController controller, NationInstance nation) {
        this.controller = controller;
        this.nation = nation;
        nationNumber = nation.getNation();
        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        setBackground(Color.LIGHT_GRAY);

        createComponents();
        layoutComponents();
        updateSummary();
    }

    public void createComponents() {
        nationSummaryTitle = new JLabel(GameMsg.getString("nation.pos." + nationNumber) + " " + GameMsg.getString("nationSummary"));

        unitInfo = new NationUnitInfo(nationNumber);
        regionInfo = new NationRegionInfo(nationNumber);
//        politicalInfo = new PoliticalInfo(nationNumber);
        productionInfo = new NationProductInfo();

    }

    public void layoutComponents() {
        JPanel titlePanel = new JPanel();
        titlePanel.setOpaque(false);
        titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.LINE_AXIS));
        titlePanel.add(Box.createHorizontalGlue());
        titlePanel.add(Box.createHorizontalStrut(10));
        titlePanel.add(nationSummaryTitle);
        titlePanel.add(Box.createHorizontalStrut(10));
        titlePanel.add(Box.createHorizontalGlue());
        add(Box.createVerticalStrut(10));
        add(titlePanel);
        add(Box.createVerticalStrut(10));
        add(unitInfo);
        add(regionInfo);
//        add(politicalInfo);

        add(productionInfo);
    }

    public void updateSummary() {
        //Military
        unitInfo.setUnits(nation.getMilitary());

        //Territory
        regionInfo.setRegions(nation.getTerritory());

        //Political Status
//        politicalInfo.doSomething();

        //Production
        productionInfo.setProducts(nation.getProductionValue(), nation.getProductionPoints(), nation.getPaps());

        controller.getDisplay().refresh();
    }

    private JLabel nationSummaryTitle;
    private NationUnitInfo unitInfo;
    private NationRegionInfo regionInfo;
    private NationProductInfo productionInfo;
    //War stuff? aka Political Status
}
